/**
 * Created by lsx on 2017/5/12.
 */
define(['jquery','mui'], function ($,Mui) {

    for(var i=0;i<document.querySelectorAll('.recharge-btn').length;i++) {
        (function (i) {
            document.querySelectorAll('.recharge-btn')[i].addEventListener('tap', function (e) {
                var user_card_id=$(this)[0].attributes.card_id.value;
                var btnArray = ['取消', '确定下单'];
                var html="<div style='padding: 10px;font-size: 14px'>" +
                    "<div style='text-align: left;padding-bottom: 3px'>水卡编号：234234"+i+"</div>" +
                    "<div style='text-align: left;padding-bottom: 3px'>水卡名称：234234</div>" +
                    "<div style='text-align: left;padding-bottom: 3px'>　　次数：234234</div>" +
                    "</div>";
                Mui.confirm(html, '温馨提示', btnArray, function(e) {
                    if (e.index == 1) {
                        $.ajax({
                            url:order_url+'/user_card_id/'+user_card_id,
                            success:function (res) {
                                if(res.success){
                                    mui.toast(res.message);
                                    var url=pay_url+"/order_id/"+res.data.order_id;
                                    setTimeout("window.location.href='"+url+"'",1000);
                                }
                            }
                        })
                    } else {

                    }
                })
            });
        })(i);
    }
});
